Imports System.Xml
Imports System.Globalization
Namespace Common.Rss.Version20
    Public Class Document
        Inherits XmlDocument
        Dim _Channel As Channel

        Public ReadOnly Property Channel() As Channel
            Get
                Return _Channel
            End Get
        End Property
        Sub New()
            MyBase.New()
            _Channel = New Channel()
        End Sub
        Sub New(ByVal document As XmlDocument)
            MyBase.New()
            _Channel = New Channel(Me.SelectSingleNode("//channel"))
        End Sub
        Public Function ToXMLDocument(ByVal encoding As String) As XmlDocument
            Me.RemoveAll()
            Dim xDeclaration As XmlDeclaration = Me.CreateXmlDeclaration("1.0", encoding, "")
            Dim xRssElement As XmlElement = Me.CreateElement("rss")
            xRssElement.SetAttribute("version", "2.0")
            xRssElement.AppendChild(_Channel.ToXMLElement(Me))
            Me.AppendChild(xDeclaration)
            Me.AppendChild(xRssElement)
            Return Me
        End Function
        Public Overrides Function ToString() As String
            Return Me.ToXMLDocument("utf-8").OuterXml
        End Function
    End Class
End Namespace